<!DOCTYPE html>
<!--
Copyright 2016 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="/tracing/core/test_utils.html">
<link rel="import" href="/tracing/extras/chrome/blame_context/blame_context.html">

<script>
'use strict';

tr.b.unittest.testSuite(function() {
  const BlameContextSnapshot = tr.e.chrome.BlameContextSnapshot;
  const BlameContextInstance = tr.e.chrome.BlameContextInstance;

  function TestBlameContextSnapshot() {
    BlameContextSnapshot.apply(this, arguments);
  }

  TestBlameContextSnapshot.prototype = {
    __proto__: BlameContextSnapshot.prototype,

    get userFriendlyName() {
      return 'Test';
    }
  };

  tr.model.ObjectSnapshot.subTypes.register(
      TestBlameContextSnapshot,
      {typeName: 'Test'});

  function TestBlameContextInstance() {
    BlameContextInstance.apply(this, arguments);
  }

  TestBlameContextInstance.prototype = {
    __proto__: BlameContextInstance.prototype,

    get blameContextType() {
      return 'Test';
    }
  };

  tr.model.ObjectInstance.subTypes.register(
      TestBlameContextInstance,
      {typeName: 'Test'});

  const TestUtils = tr.c.TestUtils;

  test('parentContext', function() {
    let parent;
    let child;
    TestUtils.newModel(function(model) {
      parent = TestUtils.newSnapshot(model, {id: '0x1', name: 'Test'});
      child = TestUtils.newSnapshot(model, {id: '0x2', name: 'Test',
        args: {parent: {id_ref: '0x1'}}});
    });

    assert.isTrue(child.parentContext === parent);
  });
});
</script>
